//
//  DescribeCell.m
//  PropertyMananger
//
//  Created by bh on 17/1/16.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "DescribeCell.h"

@implementation DescribeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *cellID = @"DescribeCellID";
    DescribeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil) {
        cell = [[DescribeCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    //选中cell的颜色 -无色
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
    
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.titleLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.titleLabel];
        
        self.titleLabel.textColor = BHColor(102, 102, 102);
        self.titleLabel.font = BHFont(15);
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(self).with.offset(10);
            make.size.mas_equalTo(CGSizeMake(100, 25));
        }];
        
        self.lineView = [[UIView alloc]init];
        [self.contentView addSubview:self.lineView];
        self.lineView.backgroundColor = BHGrayColor;
        
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.contentView).with.offset(15);
            make.bottom.equalTo(self.contentView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW - 15, 1));
        }];

        
        self.infoLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.infoLabel];
        
        self.infoLabel.textColor = BHColor(51, 51, 51);
        self.infoLabel.font = BHFont(15);
        self.infoLabel.textAlignment = NSTextAlignmentLeft;
        self.infoLabel.numberOfLines = 0;
        
        [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.titleLabel).with.offset(10);
            make.top.equalTo(self.titleLabel.mas_bottom).with.offset(0);
             make.right.mas_offset(-15);
           // make.bottom.mas_offset(-5);
        }];
        
        UIView * lineView = [[UIView alloc]init];
        [self.contentView addSubview:lineView];
        lineView.backgroundColor = BHGrayColor;
        
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(self.contentView).with.offset(15);
            make.bottom.equalTo(self.contentView).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW - 15, 1));
        }];

        
    }
    return self;
}
+ (CGFloat)cellMoreHeightWiht:(MyPublicModel *)model
{
    //展开后得高度(计算出文本内容的高度+固定控件的高度)
        NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
        NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
        CGSize size = [model.ReplyContent boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
        
        if(size.height < 30){
            size.height = 30;
        }
        return size.height + 50;
    
}
+ (CGFloat)cellDescHeightWiht:(MyPublicModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.RepairDesc boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 50;

}
+ (CGFloat)cellAddressHeightWiht:(MyPublicModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.RepairAddr boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 30;

}
+ (CGFloat)cellComplainDescHeightWiht:(MyComplainListModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.Contents boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 50;

}
+ (CGFloat)cellComplainReplyResultHeightWiht:(MyComplainListModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.ReplyContent boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 50;

}
+ (CGFloat)cellWorkAddressHeightWiht:(PublicRepairModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.RepairAddr boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 30;

}
+ (CGFloat)cellWorkDescQuestionHeightWiht:(PublicRepairModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.RepairDesc boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 50;

}
+ (CGFloat)cellComplainDescQuestionHeightWiht:(ComplainModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.Contents boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 50;


}
+ (CGFloat)cellEquipRepairContentHeightWiht:(EquipmentRepairModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.MaintenanceCSontent boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 50;

}
+ (CGFloat)cellEquipRepairConditionHeightWiht:(EquipmentRepairModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.MaintenanceCondition boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 50;

}
+ (CGFloat)cellWorkResultHeightWiht:(PublicRepairModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.ReplyContent boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 50;

}
+ (CGFloat)cellWorkComplainReplyResultHeightWiht:(ComplainModel *)model{

    //展开后得高度(计算出文本内容的高度+固定控件的高度)
    NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
    NSStringDrawingOptions option = (NSStringDrawingOptions)(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading);
    CGSize size = [model.ReplyContent boundingRectWithSize:CGSizeMake(BHscreenW - 20, MAXFLOAT) options:option attributes:attribute context:nil].size;
    
    if(size.height < 30){
        size.height = 30;
    }
    return size.height + 50;

}
- (void)setModel:(MyPublicModel *)model{

    _model = model;
    
    self.infoLabel.text = model.RepairDesc;

}
@end
